{template 'common/header'}
<div class="main">
	<ul class="nav nav-tabs">
		<li{if $_GPC['do'] == 'manage'} class="active"{/if}><a href="{php echo $this->createWebUrl('manage');}">活动管理</a></li>
		<li{if $_GPC['do'] == 'fanslist'} class="active"{/if}><a href="{php echo $this->createWebUrl('fanslist',array('rid' => $rid));}">参与粉丝</a></li>
		<li{if $_GPC['do'] == 'awardlist'} class="active"{/if}><a href="{php echo $this->createWebUrl('awardlist',array('rid' => $rid));}">中奖名单</a></li>
		<li{if $_GPC['do'] == 'cashprize'} class="active"{/if}><a href="{php echo $this->createWebUrl('cashprize',array('rid' => $rid));}">提现管理</a></li>
		<!-- <li{if $_GPC['do'] == 'rankinglist'} class="active"{/if}><a href="{php echo $this->createWebUrl('rankinglist',array('rid' => $rid));}">状元榜单</a></li> -->
		<!-- <li{if $_GPC['do'] == 'jifenlist'} class="active"{/if}><a href="{php echo $this->createWebUrl('jifenlist',array('rid' => $rid));}">积分榜</a></li> -->
		<li><a href="{php echo url('platform/reply/post',array('m'=>'haoman_dpm', 'rid' => $rid));}">编辑规则</a></li>
	</ul>
    <div class="panel panel-info">
	<div class="panel-heading">筛选</div>
	<div class="panel-body">
		<form action="./index.php" method="get" class="form-horizontal" role="form">
			<input type="hidden" name="c" value="site" />
			<input type="hidden" name="a" value="entry" />
        	<input type="hidden" name="m" value="haoman_dpm" />
        	<input type="hidden" name="do" value="fanslist" />
        	<input type="hidden" name="rid" value="{$_GPC['rid']}" />
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">微信名称</label>
				<div class="col-xs-12 col-sm-8 col-lg-9">
					<input class="form-control" name="nickname" id="" type="text" value="{$_GPC['nickname']}" placeholder="名称">
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">openid</label>
				<div class="col-xs-12 col-sm-8 col-lg-9">
					<input class="form-control" name="from_user" id="12" type="text" value="{$_GPC['from_user']}" placeholder="openid">
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">性别</label>
				<div class="col-xs-12 col-sm-8 col-lg-9">
					<select name="sex" class="form-control" style="float:left">
						<option value="" {if $_GPC['sex']==''}selected{/if}>全部</option>
						<option value="1" {if $_GPC['sex']=='1'}selected{/if}>女</option>
						<option value="2" {if $_GPC['sex']=='2'}selected{/if}>男</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">状态</label>
				<div class="col-xs-12 col-sm-8 col-lg-9">
					<select name="zhongjiang" class="form-control" style="float:left">
						<option value="" {if $_GPC['zhongjiang']==''}selected{/if}>全部</option>
						<option value="1" {if $_GPC['zhongjiang']=='0'}selected{/if}>未中奖</option>
						<option value="2" {if $_GPC['zhongjiang']=='1'}selected{/if}>已中奖</option>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">手机号码</label>
				<div class="col-xs-12 col-sm-8 col-lg-9">
					<input class="form-control" name="mobile" id="" type="text" value="{$_GPC['mobile']}" placeholder="手机号码"> 
				</div>
				<div class=" col-xs-12 col-sm-2 col-lg-2">
					<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
				</div>
			</div>			

		</form>
	</div>
</div>
	<div class="panel panel-default">
		<div class="panel-heading">删除测试帐号数据</div>
		<form class="form-horizontal">
			<div class="form-group" style="margin-top: 14px;">
				<label class="col-xs-12 col-sm-2 col-md-2  col-lg-1 control-label ">微信openid</label>
				<div class="col-xs-12 col-sm-8 col-lg-9">
					<input type="text" id="del_openid" class="form-control" placeholder="" name="del_openid" value="">
				</div>
				<div class=" col-xs-12 col-sm-2 col-lg-2">
					<button class="btn btn-default delete"> <span class="delete">删除</span></button>
				</div>
			</div>
		</form>
	</div>
	 <button class="btn btn-success" onclick="location.href='{php echo $this->createWebUrl('download',array('rid'=>$_GPC['rid']))}'" type="button"><i class="fa fa-search"></i> 导出数据</button>
	<button class="btn btn-success" style="display: none" onclick="location.href='{php echo $this->createWebUrl('del_txt')}'" type="button">清除桌面应用数据</button>

	<div class="panel panel-default">
<div class="panel-heading">

	<div class="alert" style="margin-bottom:0;">
		本次活动参与粉丝总数：{$num1}个　　中奖数：{$num2}个　　未中奖：{$num3}个　　 
	</div>

</div>
	<form method="post" class="form-horizontal" id="formfans">
	<input type="hidden" name="op" value="del" />
	<div style="position:relative">
		<div class="panel-body table-responsive">
			<table class="table table-hover" style="position:relative;table-layout: auto;">
			<thead class="navbar-inner">
				<tr>
					<th class='with-checkbox' style="width:30px;">
						<input type="checkbox" class="check_all" />
					</th>
					<th style="width:50px;">序号</th>
					<th style="width:80px;">头像</th>
					<th style="width:100px;">微信名称</th>
					<th style="width:100px;">真实姓名</th>
					<th style="width:120px;">手机号码</th>
					<th style="width:320px;">微信OpenId</th>
					<th style="width:150px;">公司/部门</th>
					<th style="width:150px;">参与时间</th>
					<th style="width:120px;">详情</th>
					<th style="width:120px;">性别</th>
					{if $reply['isbaoming']==1}
					 <th style="width:120px;">报名状态</th>
				     {/if}
					<th style="width:180px;">操作</th>
				</tr>
			</thead>
			<tbody>
				{loop $list $row}
				<tr>
					<td class="with-checkbox"><input type="checkbox" name="check" value="{$row['id']}"></td>
					<td>{$row['id']}</td>
					<td><img style="width: 75px;height: 75px" src="{php echo tomedia($row['avatar'])}"></td>
					<td> {$row['nickname']}</td>
					<td> {$row['realname']}</td>
					<td>{$row['mobile']}</td>
					<td>{$row['from_user']}</td>
					<td>{$row['address']}</td>
					<td>{php echo date('Y/m/d H:i',$row['createtime']);}</td>
					<td>{if $row['zhongjiang']==0}未中奖{else}<a href="javascript:void(0)" id="{$row['id']}" class="btn btn-success btn-sm awardinfo" style="width:130px;" data-toggle="tooltip" data-placement="top" title="中奖详情"><i class="fa fa-gift"></i> 中奖详情[{$row['awardinfo']}]</a>{/if}</td>
					<td>
						{if $row['sex']== 1}
						<a href="{php echo $this->createWebUrl('SetfansSex',array('sex'=>2,'fansid'=>$row['id']))}" class="btn btn-primary btn-sm " style="width:60px;">男</a>
						{elseif $row['sex']== 2}
						<a href="{php echo $this->createWebUrl('SetfansSex',array('sex'=>1,'fansid'=>$row['id']))}" class="btn btn-success btn-sm " style="width:60px;">女</a>
						{else}
						<a href="{php echo $this->createWebUrl('SetfansSex',array('sex'=>1,'fansid'=>$row['id']))}" class="btn btn-success btn-sm " style="width:60px;">未填写</a>
						{/if}
					</td>
					{if $reply['isbaoming']==1}
						<td>{if $row['isbaoming']==1}
							<button class="btn btn-success" disabled > <span>已经报名</span></button>
						{else}
						<button class="btn btn-default" disabled> <span>已经签到</span></button>
						{/if}
					</td>
			      	{/if}
					<td>
					{if $row['is_back']!= 0}
					<a href="{php echo $this->createWebUrl('SetfansStatus',array('is_back'=>0,'fansid'=>$row['id']))}" class="btn btn-primary btn-sm lahei" style="width:60px;">恢复</a>
					{else}
					<a href="{php echo $this->createWebUrl('SetfansStatus',array('is_back'=>1,'fansid'=>$row['id']))}" class="btn btn-success btn-sm lahei" style="width:60px;">拉黑</a>
					{/if}
						{if $fanshb['is_setadmin']==1}
							{if empty($row['is_admin'])}
							<a href="{php echo $this->createWebUrl('SetfansStatus',array('op'=>'set_admin','fansid'=>$row['id'],'rid'=>$row['rid']))}" class="btn btn-info btn-sm " >设置为管理员</a>
							{else}
							<a href="{php echo $this->createWebUrl('SetfansStatus',array('op'=>'del_admin','fansid'=>$row['id'],'rid'=>$row['rid']))}" class="btn btn-danger btn-sm " >取消管理员</a>
							{/if}
						{/if}
					</td>

				</tr>
				{/loop}
				<tr>
					<td colspan="2">
						<input type="button" class="btn btn-primary" name="lahei_fans" value="批量拉黑" />
					</td>
					<td colspan="2">
						<input type="button" class="btn btn-danger" name="deleteall_fans" value="批量删除" />
					</td>
				</tr>
			</tbody>
		</table>
	</div>
</div>
</form>
</div>
{$pager}
</div>

<div style="width: 100%;height: 100%;background: rgba(0,0,0,0.6);position: fixed;top: 0px;left: 0px;display: none;" class="cztl">
	<div style="width: 60%;height: 300px;background: #eee;position: absolute;top: 50%;left:50%;margin-left: -30%;margin-top: -150px;">
		<div style="height: 45px;width: 50%;position: absolute;top: 50%;left: 50%;margin-top: -22px;margin-left: -25%">
			<input type="number" placeholder="请输入要修改的值" style="width: 100%;height: 100%" class="number">
			<div style="margin-top: 20px;text-align: center">
				<button class="btn btn-success isokl" style="width: 120px;">确定</button>
				<button class="btn btn-default isnot" style="width: 120px;">取消</button>
			</div>

		</div>

	</div>
</div>

<div id="guanbi" class="hide">
	<span type="button" class="pull-right btn btn-primary" data-dismiss="modal" aria-hidden="true">关闭</span>
</div>
<script>
	require(['jquery', 'util'], function($, u){


		$(".delete").click(function(){
			var del_openid = $("#del_openid").val();

			var submitData = {
				del_openid:del_openid,

			}

			$.post("{php echo $this->createWebUrl('delete_openid',array('rid'=>$rid))}", submitData, function(data) {

				if (data.success == 1) {

					alert(data.msg);
					location.href="{php echo $this->createWebUrl('fanslist', array('rid' => $rid))}";

				} else {
					alert(data.msg);
					location.href="{php echo $this->createWebUrl('fanslist', array('rid' => $rid))}";
				}
			},"json")

			return false;
		})

		$('.awardinfo').click(function(){
			var uid = parseInt($(this).attr('id'));
			$.get("{php echo url('site/entry/axq',array('m' => 'haoman_dpm','rid' => $rid))}&uid=" + uid, function(data){
				if(data == 'dataerr') {
					u.message('未找到指定粉丝', '', 'error');
				} else {
					var obj = u.dialog('中奖详细情况', data, $('#guanbi').html());
				}
				obj.modal('show');
			});
		})

		$(".recharge").click(function(){
			$('.cztl').show()

			var num_ids = $(this).data("id");

			$(".isokl").click(function(){
				var nums = $(".number").val();
				if(nums==''){
					alert("请输入正确的状元数")
				}
				var submitData = {
					nums:nums,
					num_ids:num_ids,
				}
				$.post('{php echo $this->createWebUrl('chongzhi')}', submitData, function(data) {

					if (data.success == 1) {

						alert(data.msg);
						location.href="{php echo $this->createWebUrl('fanslist', array('rid' => $rid))}";

					} else {
						alert(data.msg);
					}
				},"json")
			})
			return false;
		});
		$(".isnot").click(function(){
			$('.cztl').hide();
		})
	});

	$(function(){

		$(".check_all").click(function(){
			var checked = $(this).get(0).checked;

			$("input[type=checkbox]").attr("checked",checked);
		});
		$("input[name=lahei_fans]").click(function(){
			var check = $("input:checked");

			if(check.length<2){
				alert('请选择要拉黑的记录!');
				return false;
			}
			if( confirm("确认要拉黑选择的记录?")){
				var id = new Array();
				check.each(function(i){
					id[i] = $(this).val();
				});
				$.post('{php echo $this->createWebUrl('Back_fans')}', {idArr:id},function(data){
					if (data.flag ==1)
					{
						alert(data.msg);
						location.reload();
					} else {
						alert(data.msg);
					}


				},'json');
			}

		});
		$("input[name=deleteall_fans]").click(function(){
			var check = $("input:checked");

			if(check.length<2){
				alert('请选择要删除的记录!');
				return false;
			}
			if( confirm("确认要删除选择的记录?")){
				var id = new Array();
				check.each(function(i){
					id[i] = $(this).val();
				});
				$.post('{php echo $this->createWebUrl('Deleall_fans',array('rid'=>$rid))}', {idArr:id},function(data){
					if (data.flag ==1)
					{
						alert(data.msg);
						location.reload();
					} else {
						alert(data.msg);
					}


				},'json');
			}

		});
	});
</script>
{template 'common/footer'}